/**
 * 
 */
package neptune.manager.validator.rules.netif;

import neptune.manager.model.topology.NetworkInterface;
import neptune.manager.utils.Logger.MessageType;
import neptune.manager.validator.ValidatorResult;
import neptune.manager.validator.ValidatorRule;
import neptune.manager.validator.Validator.Status;

/**
 * Verifica che l'interfaccia di controllo abbia come nome eth0
 * 
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 * 
 */
public class ControlInterfaceNameRule extends ValidatorRule<NetworkInterface> {

	@Override
	public String getName() {
		return "ControlInterfaceNameRule";
	}

	@Override
	protected ValidatorResult validationAlgorithm(NetworkInterface toValidate,
			ValidatorResult result) {

		if (toValidate.getControlAddress() != null) { // L'interfaccia e' di
			// controllo
			if (!toValidate.getInterfaceName().equals("eth0")) {
				result.setStatus(Status.ERROR);
				result.getLog().addMessage(
						"Interface '" + toValidate.getInterfaceName()
								+ "' is a control interface but "
								+ "its name is not 'eth0'", MessageType.ERROR);
			}
		}

		return result;
	}

}
